package Text_26;

import java.util.ArrayList;
import java.util.Scanner;

public class Code {

	public static void main(String[] args) {
		//键盘录入1-100的数，放入集合
				//直到集合中所有数据之和超过200
				ArrayList<Integer> list = new ArrayList();
				Scanner sc = new Scanner(System.in);
				int sum = 0;
				while(true) {
					System.out.println("请输入小于200的数字：");
					String num = sc.nextLine();
					int num1 = Integer.parseInt(num);
					if(1>num1||num1>200) {
						System.out.println("输入错误");
						continue;
					}
					list.add(num1);
					if(getSum(list)>200) {
						System.out.println("满足条件");
						break;
					}
				}
				for(int i=0;i<list.size();i++) {
					System.out.print(list.get(i)+" ");
				}
			}
			public static int getSum(ArrayList<Integer> list) {
				int sum =0;
				for (int i=0;i<list.size();i++) {
					int num = list.get(i);
					sum = sum + num;
				}
				return sum;

	}

}
